package com.atwy.sort;

import com.atwy.tree.HeapSortDemo;

import java.util.Arrays;

public class TestMain {

    public static void main(String[] args) {
        int max = 8000000;
        int arraySource[] = new int[max];
        for (int i = 0; i < max; i++) {
            arraySource[i] = (int) (Math.random() * 80000000);
        }
        long start,end,total;

        /*System.out.println("=======");
        int[] bubbleArray = Arrays.copyOf(arraySource, arraySource.length);
        start = System.currentTimeMillis();
        System.out.println("冒泡排序开始:" + start);
        BubbleSorting.sort(bubbleArray);
        end = System.currentTimeMillis();
        System.out.println("冒泡排序结束:" + end);
        total = end - start;
        System.out.println("冒泡总耗时" + total);*/

        /*System.out.println("=======");
        int[] selectArray = Arrays.copyOf(arraySource, arraySource.length);
        start = System.currentTimeMillis();
        System.out.println("选择排序开始:" + start);
        SelectSorting.sort(selectArray);
        end = System.currentTimeMillis();
        System.out.println("选择排序结束:" + end);
        total = end - start;
        System.out.println("选择总耗时" + total);*/

        System.out.println("=======");
        int[] shellArray = Arrays.copyOf(arraySource, arraySource.length);
        start = System.currentTimeMillis();
        System.out.println("希尔排序开始:" + start);
        ShellSorting.sort(shellArray);
        end = System.currentTimeMillis();
        System.out.println("希尔排序结束:" + end);
        total = end - start;
        System.out.println("希尔总耗时" + total);

       /* System.out.println("=======");
        int[] insertionArray = Arrays.copyOf(arraySource, arraySource.length);
        start = System.currentTimeMillis();
        System.out.println("插入排序开始:" + start);
        InsertionSort.sort(insertionArray);
        end = System.currentTimeMillis();
        System.out.println("插入排序结束:" + end);
        total = end - start;
        System.out.println("插入总耗时" + total);*/

        System.out.println("=======");
        int[] quickArray = Arrays.copyOf(arraySource, arraySource.length);
        start = System.currentTimeMillis();
        System.out.println("快速排序开始:" + start);
        QuickSorting.sort(quickArray);
        end = System.currentTimeMillis();
        System.out.println("快速排序结束:" + end);
        total = end - start;
        System.out.println("快速总耗时" + total);

        System.out.println("=======");
        int[] mergeArray = Arrays.copyOf(arraySource, arraySource.length);
        start = System.currentTimeMillis();
        System.out.println("归并排序开始:" + start);
        MergeSorting.sort(mergeArray);
        end = System.currentTimeMillis();
        System.out.println("归并排序结束:" + end);
        total = end - start;
        System.out.println("归并总耗时" + total);

        System.out.println("=======");
        int[] radixArray = Arrays.copyOf(arraySource, arraySource.length);
        start = System.currentTimeMillis();
        System.out.println("基数排序开始:" + start);
        RadixSorting.sort(radixArray);
        end = System.currentTimeMillis();
        System.out.println("基数排序结束:" + end);
        total = end - start;
        System.out.println("基数总耗时" + total);


        System.out.println("=======");
        int[] heapArray = Arrays.copyOf(arraySource, arraySource.length);
        start = System.currentTimeMillis();
        System.out.println("堆排序开始:" + start);
        HeapSortDemo.sort(heapArray);
        end = System.currentTimeMillis();
        System.out.println("堆排序结束:" + end);
        total = end - start;
        System.out.println("堆排序总耗时" + total);

    }

}
